﻿#ifndef BCITARGET_H
#define BCITARGET_H

#include <QObject>
#include <QPainter>
#include <QSoundEffect>

#include "qbcitargetinterface.h"

class QBciTarget : public QBciTargetInterface {
public:
  explicit QBciTarget();
  QBciTarget(const int &id, const QString &label);

//  void rotate(const qreal &degree);
//  void setSetImage(const QString &mapPath) { SetImage = QImage(mapPath); }
//  void setSetImage(const QImage &src) { SetImage = src; }
//  void setUnsetImage(const QString &mapPath) { UnsetImage = QImage(mapPath); }
//  void setUnsetPixmap(const QImage &src) { UnsetImage = src; }

  void setStatus(const bool &flag) { Status = flag; }
  virtual void set() override {
    Status = true;
    if (ifUseSoundEffect) {
      SoundEffect.play();
    }
  }
  virtual void reset() override { Status = false; }
  void setSound(const QString &source) {
    SoundEffect.setSource(QUrl::fromLocalFile(source));
    SoundEffect.setLoopCount(1);
    SoundEffect.setVolume(1.0f);
    ifUseSoundEffect = true;
  }

private:
  QSoundEffect SoundEffect;
  bool ifUseSoundEffect = false;

//  QImage SetImage;
//  QImage UnsetImage;

private:
  virtual void stylePaint(QPainter *painter) override;
};


class QBciRectTarget : public QBciTargetInterface {
public:
  explicit QBciRectTarget();
  QBciRectTarget(const QString &label);

  void setStatus(const bool &flag) { Status = flag; }
  virtual void set() override {
    Status = true;
    if (ifUseSoundEffect) {
      SoundEffect.play();
    }
  }
  virtual void reset() override { Status = false; }
  void setSound(const QString &source) {
    SoundEffect.setSource(QUrl::fromLocalFile(source));
    SoundEffect.setLoopCount(1);
    SoundEffect.setVolume(1.0f);
    ifUseSoundEffect = true;
  }

protected:
  virtual void stylePaint(QPainter *painter) override;

private:
  QSoundEffect SoundEffect;
  bool ifUseSoundEffect = false;

};

#endif // BCITARGET_H
